package com.lemon.smartsafety.ui.fragment.fire;

import com.lemon.smartsafety.R;
import com.lemon.smartsafety.app.AppService;
import com.lemon.smartsafety.app.BundleKey;
import com.lemon.smartsafety.entity.common.PanelRcvBaseDataI;
import com.lemon.smartsafety.entity.common.PanelRcvBaseListItem;
import com.lemon.smartsafety.entity.event.common.PanelEvent;
import com.lemon.smartsafety.entity.safe.company.CompanyInfo;
import com.lemon.smartsafety.listener.RecyclerTClickListener;
import com.lemon.smartsafety.result.address.CompanySafeTestMode;
import com.lemon.smartsafety.result.address.ModCompanyMessageMode;
import com.lemon.smartsafety.ui.adapter.common.PanelRcvBaseAdapter;
import com.lemon.smartsafety.ui.adapter.common.RcvViewType;
import com.lemon.smartsafety.ui.adapter.safe.data.ItemTag;
import com.lemon.smartsafetynew.ui.fragment.base.BaseLocalListFragment;
import com.lemon.smartsafety.utils.app.ToastUtil;
import com.lemon.smartsafety.utils.app.UserTypeHelper;
import com.lemon.smartsafety.utils.common.LoggerHelper;
import com.lemon.smartsafety.utils.common.StringUtils;

import kale.adapter.LemonRcvAdapter;

/**
 * 项目名称：workspace
 * 类描述：
 * 创建人：Fargo
 * 创建时间：2016/8/4 14:47
 * 修改人：Fargo
 * 修改时间：2016/8/4 14:47
 * 修改备注：
 */
public class FirefightingMainFragment extends BaseLocalListFragment<PanelRcvBaseDataI> implements RecyclerTClickListener<PanelRcvBaseDataI<ItemTag>> {

    private CompanyInfo mCompanyInfo = null;


    private LoggerHelper loggerHelper = new LoggerHelper(FirefightingMainFragment.class);

    private ModCompanyMessageMode modCompanyMessageMode;

    private CompanySafeTestMode companySafeTestMode;


    private boolean isHold=false;

    public static FirefightingMainFragment newInstance() {
        return new FirefightingMainFragment();
    }

    private void initData() {
        PanelRcvBaseListItem dataHead1 = new PanelRcvBaseListItem();
        dataHead1.setPanelViewType(RcvViewType.PanelViewType.TYPE_SECTION_HEAD);
        mDataList.add(dataHead1);


        PanelRcvBaseListItem dataTitle = new PanelRcvBaseListItem();
        dataTitle.setPanelViewType(RcvViewType.PanelViewType.TYPE_TITLE);
        if (mCompanyInfo != null) {
            dataTitle.setTitle(StringUtils.nullValue(mCompanyInfo.getCompany_name()));
        }
        mDataList.add(dataTitle);


        PanelRcvBaseListItem dataHead2 = new PanelRcvBaseListItem();
        dataHead2.setPanelViewType(RcvViewType.PanelViewType.TYPE_SECTION_HEAD);
        mDataList.add(dataHead2);

        //用户类型
        PanelRcvBaseListItem itemCheck = new PanelRcvBaseListItem();
        itemCheck.setPanelViewType(RcvViewType.PanelViewType.TYPE_COMMON_ITEM);
        itemCheck.setTitle(getString(R.string.role_title));
        itemCheck.setValue(UserTypeHelper.getUserTypeName());
        itemCheck.setShowArrow(false);
        itemCheck.setDisable(true);
        itemCheck.setIcon(R.drawable.ic_item_role);
        mDataList.add(itemCheck);


        PanelRcvBaseListItem dataHead211 = new PanelRcvBaseListItem();
        dataHead211.setPanelViewType(RcvViewType.PanelViewType.TYPE_SECTION_HEAD);
        mDataList.add(dataHead211);


        //安全巡查标题
        PanelRcvBaseListItem<ItemTag> dataHead33 = new PanelRcvBaseListItem<ItemTag>();
        dataHead33.setPanelViewType(RcvViewType.PanelViewType.TYPE_SECTION_HEAD);
        dataHead33.setTitle(getString(R.string.supervise_title));
        mDataList.add(dataHead33);

        //监督管理
        PanelRcvBaseListItem<ItemTag> itemSafeInspection = new PanelRcvBaseListItem<ItemTag>();
        itemSafeInspection.setTag(ItemTag.TAG_FIRE_MANAGE);
        itemSafeInspection.setPanelViewType(RcvViewType.PanelViewType.TYPE_COMMON_ITEM);
        itemSafeInspection.setTitle(getString(R.string.fire_manage));
        itemSafeInspection.setShowArrow(true);
        itemSafeInspection.setIcon(R.drawable.ic_data_record);
        mDataList.add(itemSafeInspection);


        //联络单位设置
        PanelRcvBaseListItem<ItemTag> itemBasicInfo = new PanelRcvBaseListItem<ItemTag>();
        itemBasicInfo.setTag(ItemTag.CONTACT_UNIT_SET);
        itemBasicInfo.setPanelViewType(RcvViewType.PanelViewType.TYPE_COMMON_ITEM);
        itemBasicInfo.setTitle(getString(R.string.contact_unit_set));
        itemBasicInfo.setShowArrow(true);
        itemBasicInfo.setIcon(R.drawable.ic_check_item_manager);
        mDataList.add(itemBasicInfo);


        //移交督办
        PanelRcvBaseListItem<ItemTag> itemSafeManager = new PanelRcvBaseListItem<ItemTag>();
        itemSafeManager.setTag(ItemTag.TURN_SUPERVISE);
        itemSafeManager.setPanelViewType(RcvViewType.PanelViewType.TYPE_COMMON_ITEM);
        itemSafeManager.setTitle(getString(R.string.turn_supervise));
        itemSafeManager.setShowArrow(true);
        itemSafeManager.setIcon(R.drawable.ic_wei_bao_record);
        mDataList.add(itemSafeManager);


        //统计研判占位
        PanelRcvBaseListItem dataHead31 = new PanelRcvBaseListItem();
        dataHead31.setPanelViewType(RcvViewType.PanelViewType.TYPE_SECTION_HEAD);
        mDataList.add(dataHead31);


        //统计研判
        PanelRcvBaseListItem<ItemTag> dataHead3 = new PanelRcvBaseListItem<ItemTag>();
        dataHead3.setPanelViewType(RcvViewType.PanelViewType.TYPE_SECTION_HEAD);
        dataHead3.setTitle(getString(R.string.statistics_title));
        mDataList.add(dataHead3);




        //综合情况
        PanelRcvBaseListItem<ItemTag> itemBuildingInfo = new PanelRcvBaseListItem<ItemTag>();
        itemBuildingInfo.setTag(ItemTag.SYNTHESIS);
        itemBuildingInfo.setPanelViewType(RcvViewType.PanelViewType.TYPE_COMMON_ITEM);
        itemBuildingInfo.setTitle(getString(R.string.synthesis));
        itemBuildingInfo.setShowArrow(true);
        itemBuildingInfo.setIcon(R.drawable.ic_item_setting);
        mDataList.add(itemBuildingInfo);


        //行业分类统计
        PanelRcvBaseListItem<ItemTag> itemCheckManager = new PanelRcvBaseListItem<ItemTag>();
        itemCheckManager.setTag(ItemTag.INDUSTRY_STATISTICS);
        itemCheckManager.setPanelViewType(RcvViewType.PanelViewType.TYPE_COMMON_ITEM);
        itemCheckManager.setTitle(getString(R.string.industry_statistics));
        itemCheckManager.setShowArrow(true);
        itemCheckManager.setIcon(R.drawable.ic_wuye_manager);
        mDataList.add(itemCheckManager);


        //常见违法行为统计
        PanelRcvBaseListItem<ItemTag> itemKeepContact = new PanelRcvBaseListItem<ItemTag>();
        itemKeepContact.setTag(ItemTag.ILLEGAL_STATISTICS);
        itemKeepContact.setPanelViewType(RcvViewType.PanelViewType.TYPE_COMMON_ITEM);
        itemKeepContact.setTitle(getString(R.string.illegal_statistics));
        itemKeepContact.setShowArrow(true);
        itemKeepContact.setIcon(R.drawable.ic_build_record);
        mDataList.add(itemKeepContact);


        PanelRcvBaseListItem dataHeadEnd = new PanelRcvBaseListItem();
        dataHeadEnd.setPanelViewType(RcvViewType.PanelViewType.TYPE_SECTION_HEAD);
        mDataList.add(dataHeadEnd);

    }

    @Override
    protected void getBaseArguments() {
        super.getBaseArguments();
        if (getArguments() != null) {
            mCompanyInfo = (CompanyInfo) getArguments().getSerializable(BundleKey.COMPANY_INFO);
        }
    }

    @Override
    protected void initViews() {
        super.initViews();

        ToastUtil.init(getActivity());
        initData();
        if (mAdapter != null) {
            mAdapter.notifyDataSetChanged();
        }


    }

    @Override
    public boolean goRefreshOnCreate() {
        return false;
    }

    @Override
    public LemonRcvAdapter<PanelRcvBaseDataI> getLemonAdapter() {
        return new PanelRcvBaseAdapter(mDataList, this);
    }


    @Override
    public void onPullRefresh() {

    }


    @Override
    public void onItemClick(PanelRcvBaseDataI<ItemTag> data, int position) {
        PanelEvent<ItemTag> event = new PanelEvent<ItemTag>();
        event.setTag(FirefightingMainFragment.class.getName());
        event.setDataI(data);
        AppService.getBus().post(event);
    }




    @Override
    public void onResume() {
        super.onResume();
        if(isHold){
            isHold=false;
        }


    }

    @Override
    public void onPause() {
        super.onPause();
        isHold=true;
    }

    @Override
    public void onStop() {
        super.onStop();
        isHold=true;
    }
}
